package com.vicarica.entity;

import java.util.Calendar;
import java.util.Date;

public class User {

	private String name;
	private String birthday_date;
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getBirthday_date() {
		return birthday_date;
	}

	public void setBirthday_date(String birthday_date) {
		this.birthday_date = birthday_date;
	}

	
	private Date getFormattedDate(){
		Date formattedDate = DateUtil.getFormattedDate(birthday_date, DateUtil.mmddyyyy);
		if (formattedDate==null){
			formattedDate=DateUtil.getFormattedDate(birthday_date, DateUtil.mmdd);
		}
		return formattedDate;
	}
	
	@Override
	public String toString() {
		//XStream stream=new XStream();
		//return (stream.toXML(this) );
		
		return name + " bd : "+ getBirthday_date()+ " fmt :"+ getFormattedBirthdayString() +"\n";
	}

	public String getFormattedBirthdayString() {
		Date date=getFormattedDate();
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		StringBuilder builder=new StringBuilder("2011");
		int month=cal.get(Calendar.MONTH);
		builder.append(month<9?"0"+(month+1):month+1);
		int day=cal.get(Calendar.DATE);
		builder.append(day<9?"0"+(day):day);
		return builder.toString();
	}
	
}
